<template>
	<view class="box">
		<view class="add_user" @click="edit(0)">
			添加+
		</view>
		<up-cell-group v-if="list && list.length>0">
			<up-cell v-for="note in list" @click="edit(note.id)" :title="note.title" :label="'发布者：'+note.nickName+' 发布时间：'+note.addTime" center arrow-direction="down">
				<template #right-icon>
					<up-icon size="36" name="arrow-right"></up-icon>
				</template>
			</up-cell>
		</up-cell-group>
		<view v-else class="cc">
			暂无记录
		</view>
	</view>
</template>

<script>
	import { BASE_IP } from '@/common/http/url.js'
	export default {
		data() {
			return {

				list: null,
			}
		},
		onShow() {
			this.user = uni.getStorageSync("user")
			if (this.user.power != 1 && this.user.power != 2) {
				uni.reLaunch({ url: '/pages/user/users' });
			}
			this.getNoteList();
		},
		methods: {
			getNoteList() {
				uni.request({
					header: { "Authorization": this.user.token },
					method: "GET",
					url: BASE_IP + "pc/note/getList",
					success: (res) => {
						console.log("通知列表：", res.data)
						if (res.statusCode == 200) {
							this.list = res.data;
						}
					}
				})
			},
			edit(id) {
				uni.navigateTo({ url: '/pagesMine/admin/noteEdit?id=' + id });
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 30rpx;
	}

	.add_user {
		position: fixed;
		right: 10rpx;
		bottom: 20%;
		border-radius: 50%;
		background: #49A0FF;
		color: #fff;
		width: 100rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		z-index: 999;
	}
</style>